use askama_axum::Template;

use chrono::NaiveDateTime;

#[derive(Clone, Debug, Template)]
#[template(path = "html/blog.html")]
pub struct ArticleDetail {
    pub id: i32,
    pub title: String,
    pub categorys: Vec<String>,
    pub content: String,
    pub create_on: NaiveDateTime,
}

impl ArticleDetail {
    pub fn new(id: i32, title: String, categorys: Vec<String>, create_on: NaiveDateTime) -> Self {
        ArticleDetail {
            id,
            title,
            categorys,
            content: String::new(),
            create_on,
        }
    }

    pub fn set_content(mut self, content: String) -> Self {
        self.content = content;
        self
    }
}
